﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace SoftwareEngineering_Project
{
    public partial class Reports : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Room room = new Room();
                SqlDataReader myreader = room.getRooms("select * from room");
                Location.DataSource = myreader;
                Location.DataTextField = "Name";
                Location.DataValueField = "Room_ID";
                Location.DataBind();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Reservation myreservation = new Reservation();
            string sqlstatement = "select ReservationID as 'ID',Res_Date as'Reservation Date', stime 'Start Time',etime as 'End Time',Reservation.Name as 'Event’s title',Organizer,room.Name as'Location' from reservation,Room Where reservation.Room_ID = Room.Room_ID AND (res_date BETWEEN '" + SDate.Text + "' AND '" + EDate.Text + "' ) and Reservation.room_ID = '" + Location.SelectedValue + "'";
            SqlDataReader myreader2 = myreservation.getReservation(sqlstatement);
            Gridreport.DataSource = myreader2;
            Gridreport.DataBind();
        }
    }
}